package com.platform.usercenter.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//import com.platform.common.log.annotation.Log;
//import com.platform.common.log.enums.BusinessType;
import com.platform.common.security.annotation.RequiresPermissions;
import com.platform.usercenter.domain.SysUserGuest;
import com.platform.usercenter.service.ISysUserGuestService;
import com.platform.common.core.web.controller.BaseController;
import com.platform.common.core.web.domain.AjaxResult;
import com.platform.common.core.utils.poi.ExcelUtil;
import com.platform.common.core.web.page.TableDataInfo;

/**
 * 游客用户信息Controller
 *
 * @author platform
 * @date 2024-12-31
 */
@RestController
@RequestMapping("/guest")
public class SysUserGuestController extends BaseController
{
    @Autowired
    private ISysUserGuestService sysUserGuestService;

    /**
     * 查询游客用户信息列表
     */
    @RequiresPermissions("usercenter:guest:list")
    @GetMapping("/list")
    public TableDataInfo list(SysUserGuest sysUserGuest)
    {
        startPage();
        List<SysUserGuest> list = sysUserGuestService.selectSysUserGuestList(sysUserGuest);
        return getDataTable(list);
    }

    /**
     * 导出游客用户信息列表
     */
    @RequiresPermissions("usercenter:guest:export")
    //@Log(title = "游客用户信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysUserGuest sysUserGuest)
    {
        List<SysUserGuest> list = sysUserGuestService.selectSysUserGuestList(sysUserGuest);
        ExcelUtil<SysUserGuest> util = new ExcelUtil<SysUserGuest>(SysUserGuest.class);
        util.exportExcel(response, list, "游客用户信息数据");
    }

    /**
     * 获取游客用户信息详细信息
     */
    @RequiresPermissions("usercenter:guest:query")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(sysUserGuestService.selectSysUserGuestByUserId(userId));
    }

    /**
     * 新增游客用户信息
     */
    @RequiresPermissions("usercenter:guest:add")
    //@Log(title = "游客用户信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUserGuest sysUserGuest)
    {
        return toAjax(sysUserGuestService.insertSysUserGuest(sysUserGuest));
    }

    /**
     * 修改游客用户信息
     */
    @RequiresPermissions("usercenter:guest:edit")
    //@Log(title = "游客用户信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserGuest sysUserGuest)
    {
        return toAjax(sysUserGuestService.updateSysUserGuest(sysUserGuest));
    }

    /**
     * 删除游客用户信息
     */
    @RequiresPermissions("usercenter:guest:remove")
    //@Log(title = "游客用户信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(sysUserGuestService.deleteSysUserGuestByUserIds(userIds));
    }
}
